

import requests
import time

t0 = time.time()

url = "https://api.siliconflow.cn/v1/chat/completions"



ask = "你是deepseek？"

while True:
    ask = input("Ask: ")
    payload = {
        "model": "deepseek-ai/DeepSeek-V3",
        "messages": [
            {"role": "system", 
            "content": "你是一位优秀的助手"},
            {   
                "role": "user",
                "content": f"{ask}"
            }
        ],
        "stream": False,
        "max_tokens": 512,
        "stop": ["null"],
        "temperature": 0.7,
        "top_p": 0.7,
        "top_k": 50,
        "frequency_penalty": 0.5,
        "n": 1,
        "response_format": {"type": "text"},
        "tools": [
            {
                "type": "function",
                "function": {
                    "description": "<string>",
                    "name": "<string>",
                    "parameters": {},
                    "strict": False
                }
            }
        ]
    }
    headers = {
        "Authorization": "Bearer sk-audblilwqesxberejtrgiedxybjphgbasslahzxdhmgpltbp",
        "Content-Type": "application/json"
    }

    response = requests.request("POST", url, json=payload, headers=headers)



    # print(response.text)


    print("====="*30)
    ask_id = response.json()['id']
    ask_type = response.json()['object']
    model_name = response.json()['model']
    message = response.json()['choices'][0]['message']['content']
    print("====="*30)
    print(f"Ask ID: {ask_id}")
    print(f"Ask Type: {ask_type}")
    print(f"Model Name: {model_name}")
    print(f"Message: {message}")


    t1 = time.time()

    print("Time taken: ", t1-t0)